package playgrounduml.ui.examples;

import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.*;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.stage.Stage;


public class Example extends Application {

	Circle circle;
	Timeline timeline;

	@SuppressWarnings("unchecked")
	public void start(Stage entry) throws Exception {
		
		Group root = new Group();
	    Scene scene = new Scene(root, 400, 300, Color.web("black", 0.50));
	    circle = new Circle(100, Color.CORNFLOWERBLUE);
	    circle.setStrokeType(StrokeType.OUTSIDE);
	    circle.setStroke(Color.BLANCHEDALMOND);	  	    
	    circle.setStrokeWidth(4);
	    
	    circle.setOnMouseEntered(new EventHandler() {	    	
			public void handle(Event e) {
				if(e.getSource() == circle) {
									
					Timeline timeline = new Timeline();
					timeline.setCycleCount(1);
					
					
					final KeyValue keyVal = new KeyValue(circle.radiusProperty(), 150);
					
					final KeyFrame keyFrame = new KeyFrame(javafx.util.Duration.millis(250), keyVal);
					
					timeline.getKeyFrames().add(keyFrame);
					timeline.play();
																				
				}			
			}    	
	    });
	    
	    final Rectangle rectBasicTimeline = new Rectangle(100, 50, 100, 50);
	    rectBasicTimeline.setFill(Color.RED);
    
	    circle.setOnMouseExited(new EventHandler() {

			public void handle(Event e) {
				Timeline timeline = new Timeline();
				timeline.setCycleCount(1);
				final KeyValue keyVal = new KeyValue(circle.radiusProperty(), 100);
				
				final KeyFrame keyFrame = new KeyFrame(javafx.util.Duration.millis(250), keyVal);
				
				timeline.getKeyFrames().add(keyFrame);
				timeline.play();												
			}
	    	
	    });
	    
	    
	    root.getChildren().add(circle);
	    
	    entry.setTitle("Example");
	    entry.setScene(scene);	 
	    entry.setResizable(true);	    
	    entry.show();	
	}
	
	public static void main(String[] args) {
		launch(args);

	}

}
